package Mike.FileOS;
import java.io.*;

public class ReadFile {
	private String mypath="";
	private BufferedReader my_buff_read=null;
	public boolean ISOPEN=false;
	public ReadFile(String path){
		mypath=path;
		File file = new File (path);
		try {
			my_buff_read = new BufferedReader (new FileReader (file));
			ISOPEN=true;
		} catch (FileNotFoundException e) {
			System.out.println("Is Path Error : "+path);
			e.printStackTrace();
		}
	}
	
	public String readline(){
		try {
			return my_buff_read.readLine();
		} catch (IOException e) {
			e.printStackTrace();
			ISOPEN=false;
		}
		return null;
	}
	public static String Read_File(String path){
		String out="";
		File file = new File (path);
	    try {
			BufferedReader buf_reader = new BufferedReader (new FileReader (file));
			do {
				String line;
				try {
					line = buf_reader.readLine();
					if (line == null) break;//end of file
					else{
						out+=line;
					}
				} catch (IOException e) {
					e.printStackTrace();
				}
				//if (line.indexOf(string_to_find) != -1) num_lines++;
			} while (true);
		} catch (FileNotFoundException e) {
			System.out.println("Is Path Error? : "+path);
			e.printStackTrace();
		}
		return out;
	}
}
